package PresentationLayer;

import DataLayer.Course;
import DataLayer.Courses;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Anthony Gentile
 */
public class View extends javax.swing.JFrame {

    String role;
    String userId;
    
    private javax.swing.JFrame n;
    /**
     * Creates new form View
     */
    public View(String role, String userId) {
        initComponents();
        
        this.role = role;
        this.userId = userId;
        
        //Depending on the user logged in certain tabs must be obliterated
        if(!role.equals("3"))
        {
            viewPane.remove(kudosPanel);
            viewPane.remove(usersPanel);
        }
        if(role.equals("1"))
        {
            newCourse.setVisible(false);
            editCourse.setVisible(false);
            newService.setVisible(false);
            editService.setVisible(false);
            newGrant.setVisible(false);
            editGrant.setVisible(false);
            newPublication.setVisible(false);
            editPublication.setVisible(false);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        viewPane = new javax.swing.JTabbedPane();
        welcomePanel = new javax.swing.JPanel();
        logoutButton = new java.awt.Button();
        loginPane = new javax.swing.JScrollPane();
        loginText = new javax.swing.JTextArea();
        coursesPanel = new javax.swing.JPanel();
        coursesPane = new javax.swing.JScrollPane();
        coursesTable = new javax.swing.JTable();
        newCourse = new javax.swing.JButton();
        editCourse = new javax.swing.JButton();
        servicesPanel = new javax.swing.JPanel();
        newService = new javax.swing.JButton();
        editService = new javax.swing.JButton();
        servicesPane = new javax.swing.JScrollPane();
        servicesTable = new javax.swing.JTable();
        grantsPanel = new javax.swing.JPanel();
        newGrant = new javax.swing.JButton();
        editGrant = new javax.swing.JButton();
        grantsPane = new javax.swing.JScrollPane();
        grantsTable = new javax.swing.JTable();
        publicationsPanel = new javax.swing.JPanel();
        newPublication = new javax.swing.JButton();
        editPublication = new javax.swing.JButton();
        publicationsPane = new javax.swing.JScrollPane();
        publicationsTable = new javax.swing.JTable();
        kudosPanel = new javax.swing.JPanel();
        newKudo = new javax.swing.JButton();
        updateKudo = new javax.swing.JButton();
        kudosPane = new javax.swing.JScrollPane();
        kudosTable = new javax.swing.JTable();
        usersPanel = new javax.swing.JPanel();
        newUser = new javax.swing.JButton();
        UpdateUser = new javax.swing.JButton();
        usersPane = new javax.swing.JScrollPane();
        usersTable = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("The Educational Editor");
        setResizable(false);

        viewPane.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                viewPaneComponentShown(evt);
            }
        });

        logoutButton.setActionCommand("logoutButton");
        logoutButton.setLabel("Logout");
        logoutButton.setName("logoutButton"); // NOI18N
        logoutButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                logoutButtonMouseClicked(evt);
            }
        });
        logoutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutButtonActionPerformed(evt);
            }
        });

        loginText.setEditable(false);
        loginText.setColumns(20);
        loginText.setLineWrap(true);
        loginText.setRows(5);
        loginText.setText("Thank you for logging in.  Above are tabs that will allow you to view and in some cases edit data.  When you are done you may logout by clicking the button below.");
        loginText.setWrapStyleWord(true);
        loginPane.setViewportView(loginText);

        org.jdesktop.layout.GroupLayout welcomePanelLayout = new org.jdesktop.layout.GroupLayout(welcomePanel);
        welcomePanel.setLayout(welcomePanelLayout);
        welcomePanelLayout.setHorizontalGroup(
            welcomePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(welcomePanelLayout.createSequentialGroup()
                .add(348, 348, 348)
                .add(logoutButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .add(org.jdesktop.layout.GroupLayout.TRAILING, welcomePanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(loginPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 353, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(27, 27, 27))
        );
        welcomePanelLayout.setVerticalGroup(
            welcomePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(welcomePanelLayout.createSequentialGroup()
                .add(69, 69, 69)
                .add(loginPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(56, 56, 56)
                .add(logoutButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        logoutButton.getAccessibleContext().setAccessibleName("logoutButton");

        viewPane.addTab("Welcome", welcomePanel);

        coursesPanel.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                coursesPanelComponentShown(evt);
            }
        });

        coursesTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null}
            },
            new String [] {
                "Faculty", "Year", "Course Number", "Course Name"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        coursesTable.getTableHeader().setReorderingAllowed(false);
        coursesPane.setViewportView(coursesTable);
        coursesTable.getColumnModel().getColumn(0).setResizable(false);
        coursesTable.getColumnModel().getColumn(1).setResizable(false);
        coursesTable.getColumnModel().getColumn(2).setResizable(false);
        coursesTable.getColumnModel().getColumn(3).setResizable(false);

        newCourse.setText("Create New");
        newCourse.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newCourseMouseClicked(evt);
            }
        });

        editCourse.setText("Update Selected");
        editCourse.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                editCourseMouseClicked(evt);
            }
        });

        org.jdesktop.layout.GroupLayout coursesPanelLayout = new org.jdesktop.layout.GroupLayout(coursesPanel);
        coursesPanel.setLayout(coursesPanelLayout);
        coursesPanelLayout.setHorizontalGroup(
            coursesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(coursesPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(coursesPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 392, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, coursesPanelLayout.createSequentialGroup()
                .add(22, 22, 22)
                .add(editCourse)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(newCourse)
                .addContainerGap())
        );
        coursesPanelLayout.setVerticalGroup(
            coursesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, coursesPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(coursesPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
                .add(18, 18, 18)
                .add(coursesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(newCourse)
                    .add(editCourse))
                .addContainerGap())
        );

        viewPane.addTab("Courses", coursesPanel);

        newService.setText("Create New");
        newService.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newServiceMouseClicked(evt);
            }
        });

        editService.setText("Update Selected");
        editService.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                editServiceMouseClicked(evt);
            }
        });

        servicesTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null}
            },
            new String [] {
                "Faculty", "Year", "Description", "Role"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        servicesTable.getTableHeader().setReorderingAllowed(false);
        servicesPane.setViewportView(servicesTable);
        servicesTable.getColumnModel().getColumn(0).setResizable(false);
        servicesTable.getColumnModel().getColumn(0).setHeaderValue("Faculty");
        servicesTable.getColumnModel().getColumn(1).setResizable(false);
        servicesTable.getColumnModel().getColumn(1).setHeaderValue("Year");
        servicesTable.getColumnModel().getColumn(2).setResizable(false);
        servicesTable.getColumnModel().getColumn(2).setHeaderValue("Description");
        servicesTable.getColumnModel().getColumn(3).setResizable(false);
        servicesTable.getColumnModel().getColumn(3).setHeaderValue("Role");

        org.jdesktop.layout.GroupLayout servicesPanelLayout = new org.jdesktop.layout.GroupLayout(servicesPanel);
        servicesPanel.setLayout(servicesPanelLayout);
        servicesPanelLayout.setHorizontalGroup(
            servicesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(servicesPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(servicesPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 392, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, servicesPanelLayout.createSequentialGroup()
                .add(22, 22, 22)
                .add(editService)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(newService)
                .addContainerGap())
        );
        servicesPanelLayout.setVerticalGroup(
            servicesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, servicesPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(servicesPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
                .add(18, 18, 18)
                .add(servicesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(newService)
                    .add(editService))
                .addContainerGap())
        );

        viewPane.addTab("Services", servicesPanel);

        newGrant.setText("Create New");
        newGrant.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newGrantMouseClicked(evt);
            }
        });

        editGrant.setText("Update Selected");
        editGrant.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                editGrantMouseClicked(evt);
            }
        });

        grantsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null}
            },
            new String [] {
                "Faculty", "Year", "Citation", "Tease", "Amount", "Status"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        grantsTable.getTableHeader().setReorderingAllowed(false);
        grantsPane.setViewportView(grantsTable);
        grantsTable.getColumnModel().getColumn(0).setResizable(false);
        grantsTable.getColumnModel().getColumn(1).setResizable(false);
        grantsTable.getColumnModel().getColumn(2).setResizable(false);
        grantsTable.getColumnModel().getColumn(3).setResizable(false);
        grantsTable.getColumnModel().getColumn(5).setResizable(false);

        org.jdesktop.layout.GroupLayout grantsPanelLayout = new org.jdesktop.layout.GroupLayout(grantsPanel);
        grantsPanel.setLayout(grantsPanelLayout);
        grantsPanelLayout.setHorizontalGroup(
            grantsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(grantsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(grantsPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 392, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, grantsPanelLayout.createSequentialGroup()
                .add(22, 22, 22)
                .add(editGrant)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(newGrant)
                .addContainerGap())
        );
        grantsPanelLayout.setVerticalGroup(
            grantsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, grantsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(grantsPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
                .add(18, 18, 18)
                .add(grantsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(newGrant)
                    .add(editGrant))
                .addContainerGap())
        );

        viewPane.addTab("Grants", grantsPanel);

        newPublication.setText("Create New");
        newPublication.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newPublicationMouseClicked(evt);
            }
        });

        editPublication.setText("Update Selected");
        editPublication.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                editPublicationMouseClicked(evt);
            }
        });

        publicationsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null}
            },
            new String [] {
                "Faculty", "Year", "Course Number", "Course Name", "Status"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        publicationsTable.getTableHeader().setReorderingAllowed(false);
        publicationsPane.setViewportView(publicationsTable);
        publicationsTable.getColumnModel().getColumn(0).setResizable(false);
        publicationsTable.getColumnModel().getColumn(1).setResizable(false);
        publicationsTable.getColumnModel().getColumn(2).setResizable(false);
        publicationsTable.getColumnModel().getColumn(3).setResizable(false);
        publicationsTable.getColumnModel().getColumn(4).setResizable(false);

        org.jdesktop.layout.GroupLayout publicationsPanelLayout = new org.jdesktop.layout.GroupLayout(publicationsPanel);
        publicationsPanel.setLayout(publicationsPanelLayout);
        publicationsPanelLayout.setHorizontalGroup(
            publicationsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(publicationsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(publicationsPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 392, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, publicationsPanelLayout.createSequentialGroup()
                .add(22, 22, 22)
                .add(editPublication)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(newPublication)
                .addContainerGap())
        );
        publicationsPanelLayout.setVerticalGroup(
            publicationsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, publicationsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(publicationsPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
                .add(18, 18, 18)
                .add(publicationsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(newPublication)
                    .add(editPublication))
                .addContainerGap())
        );

        viewPane.addTab("Publications", publicationsPanel);

        newKudo.setText("Create New");
        newKudo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newKudoMouseClicked(evt);
            }
        });

        updateKudo.setText("Update Selected");
        updateKudo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                updateKudoMouseClicked(evt);
            }
        });

        kudosTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null}
            },
            new String [] {
                "Faculty", "Year", "Kudo"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        kudosTable.getTableHeader().setReorderingAllowed(false);
        kudosPane.setViewportView(kudosTable);
        kudosTable.getColumnModel().getColumn(0).setResizable(false);
        kudosTable.getColumnModel().getColumn(1).setResizable(false);
        kudosTable.getColumnModel().getColumn(2).setResizable(false);

        org.jdesktop.layout.GroupLayout kudosPanelLayout = new org.jdesktop.layout.GroupLayout(kudosPanel);
        kudosPanel.setLayout(kudosPanelLayout);
        kudosPanelLayout.setHorizontalGroup(
            kudosPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(kudosPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(kudosPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 392, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, kudosPanelLayout.createSequentialGroup()
                .add(22, 22, 22)
                .add(updateKudo)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(newKudo)
                .addContainerGap())
        );
        kudosPanelLayout.setVerticalGroup(
            kudosPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, kudosPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(kudosPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
                .add(18, 18, 18)
                .add(kudosPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(newKudo)
                    .add(updateKudo))
                .addContainerGap())
        );

        viewPane.addTab("Kudos", kudosPanel);

        usersPanel.setEnabled(false);

        newUser.setText("Create New");
        newUser.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newUserMouseClicked(evt);
            }
        });

        UpdateUser.setText("Update Selected");
        UpdateUser.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                UpdateUserMouseClicked(evt);
            }
        });
        UpdateUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                UpdateUserActionPerformed(evt);
            }
        });

        usersTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null}
            },
            new String [] {
                "First Name", "Last Name", "E-Mail", "Role"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        usersTable.getTableHeader().setReorderingAllowed(false);
        usersPane.setViewportView(usersTable);
        usersTable.getColumnModel().getColumn(0).setResizable(false);
        usersTable.getColumnModel().getColumn(1).setResizable(false);
        usersTable.getColumnModel().getColumn(2).setResizable(false);
        usersTable.getColumnModel().getColumn(3).setResizable(false);

        org.jdesktop.layout.GroupLayout usersPanelLayout = new org.jdesktop.layout.GroupLayout(usersPanel);
        usersPanel.setLayout(usersPanelLayout);
        usersPanelLayout.setHorizontalGroup(
            usersPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(usersPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(usersPane, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 392, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, usersPanelLayout.createSequentialGroup()
                .add(22, 22, 22)
                .add(UpdateUser)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(newUser)
                .addContainerGap())
        );
        usersPanelLayout.setVerticalGroup(
            usersPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, usersPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(usersPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
                .add(18, 18, 18)
                .add(usersPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(newUser)
                    .add(UpdateUser))
                .addContainerGap())
        );

        viewPane.addTab("Users", usersPanel);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(viewPane)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, viewPane)
        );

        viewPane.getAccessibleContext().setAccessibleName("User");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Logout
     * @param evt 
     */
    private void logoutButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_logoutButtonMouseClicked
        // TODO add your handling code here:
        //System.out.println("test");
        System.exit(0);
    }//GEN-LAST:event_logoutButtonMouseClicked

    private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_logoutButtonActionPerformed

    /**
     * Opens up the Course Window to make a new Course
     * @param evt 
     */
    private void newCourseMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newCourseMouseClicked
        n = new CourseWindow(this, "Create");
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_newCourseMouseClicked

    private void UpdateUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UpdateUserActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_UpdateUserActionPerformed

    /**
     * Opens up the Course Window to edit a Course
     * @param evt 
     */
    private void editCourseMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_editCourseMouseClicked
        //This would normally pull data from the table on the page, but this
        //functionality is pending
        n = new CourseWindow(this, "484", "Update");
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_editCourseMouseClicked

    /**
     * Opens up the Service Window to make a new Service
     * @param evt 
     */
    private void newServiceMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newServiceMouseClicked
        n = new ServiceWindow(this);
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_newServiceMouseClicked

    /**
     * Opens up the Service Window to edit a Service
     * @param evt 
     */
    private void editServiceMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_editServiceMouseClicked
        //This would normally pull data from the table on the page, but this
        //functionality is pending
        n = new ServiceWindow(this, "777");
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_editServiceMouseClicked

    /**
     * Opens up the Grant Window to make a new Grant
     * @param evt 
     */
    private void newGrantMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newGrantMouseClicked
        n = new ScholarshipWindow(this);
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_newGrantMouseClicked

    /**
     * Opens up the Grant Window to edit a Course
     * @param evt 
     */
    private void editGrantMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_editGrantMouseClicked
        //This would normally pull data from the table on the page, but this
        //functionality is pending
        n = new ScholarshipWindow(this, "777");
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_editGrantMouseClicked

    /**
     * Opens up the Publication Window to make a new Publication
     * @param evt 
     */
    private void newPublicationMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newPublicationMouseClicked
        n = new PublicationWindow(this);
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_newPublicationMouseClicked

    /**
     * Opens up the Publication Window to make a new Course
     * @param evt 
     */
    private void editPublicationMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_editPublicationMouseClicked
        //This would normally pull data from the table on the page, but this
        //functionality is pending
        n = new PublicationWindow(this, "777");
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_editPublicationMouseClicked
    /**
     * Opens up the Kudo Window to make a new Kudo
     * @param evt 
     */
    private void newKudoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newKudoMouseClicked
        n = new KudoWindow(this);
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_newKudoMouseClicked

    /**
     * Opens up the Kudo Window to edit a Course
     * @param evt 
     */
    private void updateKudoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_updateKudoMouseClicked
        //This would normally pull data from the table on the page, but this
        //functionality is pending
        n = new KudoWindow(this, "777");
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_updateKudoMouseClicked

    /**
     * Opens up the User Window to make a new User
     * @param evt 
     */
    private void newUserMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newUserMouseClicked
        n = new UserWindow(this);
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_newUserMouseClicked
    
    /**
     * Opens up the User Window to edit a User
     * @param evt 
     */
    private void UpdateUserMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_UpdateUserMouseClicked
        //This would normally pull data from the table on the page, but this
        //functionality is pending
        n = new UserWindow(this, "777");
        n.setVisible(true);
        setEnabled(false);
    }//GEN-LAST:event_UpdateUserMouseClicked

    private void viewPaneComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_viewPaneComponentShown
        // TODO add your handling code here:
    }//GEN-LAST:event_viewPaneComponentShown

    /**
     * Excellent demo of dynamic table updates
     * Specifically, updates the course table every time it's seen
     * Also factors in that faculty shouldn't see other courses
     * @param evt 
     */
    private void coursesPanelComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_coursesPanelComponentShown
        //Clear old data
        DefaultTableModel coursesModel = (DefaultTableModel)coursesTable.getModel();
        for(int i = 0; i < coursesModel.getRowCount(); i++)
        {
            coursesModel.removeRow(i);
        }
        
        //Refresh with accurate data
        
        Courses courses;
        if(role.equals("1"))
        {
            courses = new Courses(userId);
        }
        else
        {
            courses = new Courses();
        }
        Course rowCourse;
        for(int j = 0; j < courses.getCourses().size(); j++)
        {
            rowCourse = courses.getCourses().get(j);
            String[] newRow = {rowCourse.getUserId(),
                               rowCourse.getYear(),
                               rowCourse.getCourseNumber(),
                               rowCourse.getCourseName()};
            coursesModel.insertRow(j,newRow);
        }
    }//GEN-LAST:event_coursesPanelComponentShown

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton UpdateUser;
    private javax.swing.JScrollPane coursesPane;
    private javax.swing.JPanel coursesPanel;
    private javax.swing.JTable coursesTable;
    private javax.swing.JButton editCourse;
    private javax.swing.JButton editGrant;
    private javax.swing.JButton editPublication;
    private javax.swing.JButton editService;
    private javax.swing.JScrollPane grantsPane;
    private javax.swing.JPanel grantsPanel;
    private javax.swing.JTable grantsTable;
    private javax.swing.JScrollPane kudosPane;
    private javax.swing.JPanel kudosPanel;
    private javax.swing.JTable kudosTable;
    private javax.swing.JScrollPane loginPane;
    private javax.swing.JTextArea loginText;
    private java.awt.Button logoutButton;
    private javax.swing.JButton newCourse;
    private javax.swing.JButton newGrant;
    private javax.swing.JButton newKudo;
    private javax.swing.JButton newPublication;
    private javax.swing.JButton newService;
    private javax.swing.JButton newUser;
    private javax.swing.JScrollPane publicationsPane;
    private javax.swing.JPanel publicationsPanel;
    private javax.swing.JTable publicationsTable;
    private javax.swing.JScrollPane servicesPane;
    private javax.swing.JPanel servicesPanel;
    private javax.swing.JTable servicesTable;
    private javax.swing.JButton updateKudo;
    private javax.swing.JScrollPane usersPane;
    private javax.swing.JPanel usersPanel;
    private javax.swing.JTable usersTable;
    private javax.swing.JTabbedPane viewPane;
    private javax.swing.JPanel welcomePanel;
    // End of variables declaration//GEN-END:variables
}
